import { defineStore } from 'pinia'
import { themeSettings } from '@/settings'
import cloneDeep from 'lodash-es/cloneDeep.js'
export const useThemeStore = defineStore('theme', {
  state() {
    return {
      darkTheme: cloneDeep(themeSettings.darkTheme),
      tags: cloneDeep(themeSettings.tags),
      naiveThemeOverrides: cloneDeep(themeSettings.naiveThemeOverrides),
    }
  },
  getters: {},
  actions: {
    lightSwitch() {
      this.darkTheme = !this.darkTheme
    },
    setTabVisible(visible) {
      this.tags.visible = visible
    },
  },
  // 开启持久化
  persist: {
    enabled: true,
    strategies: [{ key: 'THEME_CACHE', storage: localStorage, paths: ['darkTheme'] }],
  },
})
